#!/bin/sh /etc/rc.common

START=99
USE_PROCD=1

BIN="/usr/bin/subconverter"
CONF="/etc/subconverter/pref.example.ini"
LOG_FILE="/tmp/subconverter.log"

start_service() {
	procd_open_instance
	procd_set_param command "$BIN"
	procd_append_param command -f "$CONF"
	procd_append_param command -l "$LOG_FILE"
	procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
	procd_set_param limits core="unlimited"
	procd_set_param stdout 1
	procd_set_param stderr 1
	procd_close_instance
	logger -t Subconverter 'Starting Subconverter service'
}

stop_service() {
	rm -f "$LOG_FILE"
	logger -t Subconverter 'Shutting down Subconverter service'
}

reload_service() {
	logger -t Subconverter 'Restarting Subconverter service'
	stop
	sleep 2s
	start
}
